home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / progra1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-03  |  5.0 KB  |  174 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Program Closer"
  4.    ClientHeight    =   3255
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6870
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3255
  10.    ScaleWidth      =   6870
  11.    StartUpPosition =   2  'CenterScreen
  12.    Begin VB.CommandButton Command4 
  13.       Caption         =   "Exit"
  14.       Height          =   255
  15.       Left            =   2160
  16.       TabIndex        =   4
  17.       Top             =   2880
  18.       Width           =   615
  19.    End
  20.    Begin VB.Timer Timer1 
  21.       Interval        =   1
  22.       Left            =   6360
  23.       Top             =   2760
  24.    End
  25.    Begin VB.CommandButton Command3 
  26.       Caption         =   "Help"
  27.       Enabled         =   0   'False
  28.       Height          =   255
  29.       Left            =   2160
  30.       TabIndex        =   3
  31.       Top             =   2520
  32.       Width           =   615
  33.    End
  34.    Begin VB.CommandButton Command2 
  35.       Caption         =   "End Selected Task"
  36.       Enabled         =   0   'False
  37.       Height          =   255
  38.       Left            =   120
  39.       TabIndex        =   2
  40.       Top             =   2880
  41.       Width           =   1935
  42.    End
  43.    Begin VB.ListBox List1 
  44.       Height          =   1815
  45.       ItemData        =   "Form1.frx":0000
  46.       Left            =   120
  47.       List            =   "Form1.frx":0002
  48.       TabIndex        =   1
  49.       Top             =   600
  50.       Width           =   6615
  51.    End
  52.    Begin VB.CommandButton Command1 
  53.       Caption         =   "Show Running Tasks"
  54.       Height          =   255
  55.       Left            =   120
  56.       TabIndex        =   0
  57.       Top             =   2520
  58.       Width           =   1935
  59.    End
  60.    Begin VB.Label Label2 
  61.       Caption         =   $"Form1.frx":0004
  62.       Height          =   615
  63.       Left            =   2880
  64.       TabIndex        =   6
  65.       Top             =   2520
  66.       Width           =   3855
  67.       WordWrap        =   -1  'True
  68.    End
  69.    Begin VB.Label Label1 
  70.       BackColor       =   &H80000002&
  71.       Caption         =   "Program Closer by PWKraq"
  72.       BeginProperty Font 
  73.          Name            =   "MS Sans Serif"
  74.          Size            =   12
  75.          Charset         =   0
  76.          Weight          =   700
  77.          Underline       =   0   'False
  78.          Italic          =   0   'False
  79.          Strikethrough   =   0   'False
  80.       EndProperty
  81.       ForeColor       =   &H8000000E&
  82.       Height          =   375
  83.       Left            =   240
  84.       TabIndex        =   5
  85.       Top             =   120
  86.       Width           =   3375
  87.    End
  88.    Begin VB.Shape Shape2 
  89.       BorderColor     =   &H80000002&
  90.       BorderWidth     =   8
  91.       FillColor       =   &H80000002&
  92.       FillStyle       =   0  'Solid
  93.       Height          =   375
  94.       Left            =   120
  95.       Top             =   120
  96.       Width           =   6615
  97.    End
  98.    Begin VB.Shape Shape1 
  99.       BorderWidth     =   7
  100.       Height          =   3255
  101.       Left            =   0
  102.       Top             =   0
  103.       Width           =   6855
  104.    End
  105. Attribute VB_Name = "Form1"
  106. Attribute VB_GlobalNameSpace = False
  107. Attribute VB_Creatable = False
  108. Attribute VB_PredeclaredId = True
  109. Attribute VB_Exposed = False
  110. Private Declare Function GetWindow Lib "user32" _
  111. (ByVal hwnd As Long, ByVal wCmd As Long) As Long
  112. Private Declare Function GetParent Lib "user32" _
  113. (ByVal hwnd As Long) As Long
  114. Private Declare Function GetWindowTextLength Lib _
  115. "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  116. Private Declare Function GetWindowText Lib "user32" _
  117. Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal _
  118. lpString As String, ByVal cch As Long) As Long
  119. Const GW_HWNDFIRST = 0
  120. Const GW_HWNDNEXT = 2
  121. Sub LoadTaskList()
  122. Dim CurrWnd As Long
  123. Dim Length As Long
  124. Dim TaskName As String
  125. Dim parent As Long
  126. List1.Clear
  127. CurrWnd = GetWindow(Form1.hwnd, GW_HWNDFIRST)
  128. While CurrWnd <> 0
  129. parent = GetParent(CurrWnd)
  130. Length = GetWindowTextLength(CurrWnd)
  131. TaskName = Space$(Length + 1)
  132. Length = GetWindowText(CurrWnd, TaskName, Length + 1)
  133. TaskName = Left$(TaskName, Len(TaskName) - 1)
  134. If Length > 0 Then
  135.     If TaskName <> Me.Caption Then
  136.         If TaskName <> "taskmon" Then
  137.             List1.AddItem TaskName
  138.         End If
  139.     End If
  140. End If
  141. CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
  142. DoEvents
  143. End Sub
  144. Private Sub Command1_Click()
  145. LoadTaskList
  146. End Sub
  147. Private Sub Command2_Click()
  148. On Error GoTo erlevel
  149. Dim winHwnd As Long
  150. Dim RetVal As Long
  151. winHwnd = FindWindow(vbNullString, List1.Text)
  152. Debug.Print winHwnd
  153. If winHwnd <> 0 Then
  154. RetVal = PostMessage(winHwnd, &H10, 0&, 0&)
  155. If RetVal = 0 Then
  156. MsgBox "Error posting message."
  157. End If
  158. Else: MsgBox List1.Text + " is not open."
  159. End If
  160. erlevel:
  161. LoadTaskList
  162. End Sub
  163. Private Sub Command4_Click()
  164. End Sub
  165. Private Sub Form_Load()
  166. stayontop Me
  167. End Sub
  168. Private Sub Timer1_Timer()
  169. If List1.Text = "" Then
  170.     Command2.Enabled = False
  171.     Command2.Enabled = True
  172. End If
  173. End Sub
  174.